import Vue from "vue"
Vue.directive('img', {
  // DOM
  inserted: (el, binding)=>{
    let color = Math.floor(Math.random() * 1000000)
    el.style.backgroundColor = `#${color}`
    let img = new Image()
    img.src = binding.value
    img.onload = function() {
      el.style.backgroundImage = `url(${binding.value})`
    }
  }
})